<?php

namespace App\Models\Goods;

use App\Models\Common\CommonModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Goods extends CommonModel
{
    use HasFactory;

    protected $table = 'goods';

    protected $appends = ['cover'];

    public function getCoverAttribute() {
        if(count($this->thumbs)<=0)return '';
        return asset($this->thumbs[0]);
    }

    public function getThumbsAttribute($val) {
        if(empty($val)) return [];
        $temp = explode(',', $val);
        foreach ($temp as &$item) {
            $item = asset($item);
        }
        return $temp;
    }
}
